package secondBrush.doubles;

import java.util.Arrays;

public class E02Leetcode283 {
    public void moveZeroes(int[] nums) {
        if (! (nums.length > 1)) {
            return;
        }
        int slow = 0, fast = 0;
        while (fast <= nums.length - 1) {
            while (nums[fast] == 0 && fast < nums.length -1) {
                fast++;
            }

            if (nums[slow] == 0) {
                int temp = nums[slow];
                nums[slow] = nums[fast];
                nums[fast] = temp;
            }

            fast++;
            slow++;


        }



    }

    public void moveZeroes2(int[] nums) {
        int slow = 0, fast = 0;
        while (fast < nums.length) {
            if (nums[fast] != 0) {
                int temp = nums[fast];
                nums[fast] = nums[slow];
                nums[slow] = temp;

                fast++;

            }

            slow++;
        }



    }


    public static void main(String[] args) {
        int[] nums = {0, 0};
        E02Leetcode283 e02Leetcode283 = new E02Leetcode283();
        e02Leetcode283.moveZeroes2(nums);
        System.out.println(Arrays.toString(nums));
    }
}
